package com.yiquan.search.controller;

import com.yiquan.search.entity.BrowseAction;
import com.yiquan.search.entity.SearchAction;
import com.yiquan.search.entity.Video;
import com.yiquan.search.service.CollectService;
import com.yiquan.search.service.RecommendService;
import entity.Result;
import entity.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户行为采集
 * @author Tyrone
 * @date 2022/3/6 21:35
 */
@RestController
@RequestMapping("/collect")
@Slf4j
public class CollectController {

    @Autowired
    private CollectService collectService;

    @Autowired
    private RecommendService recommendService;

    /**
     * 上报用户浏览行为
     * @return
     */
    @PostMapping("/browseAction")
    public Result collectUserBrowseAction(BrowseAction browseAction){
        collectService.collectionBrowseAction(browseAction);
        return new Result(StatusCode.REQUEST_SUCCESS);
    }

    /**
     * 上报用户搜索行为
     * @param searchAction
     * @return
     */
    @PostMapping("/searchAction")
    public Result collectUserSearchAction(SearchAction searchAction){
        collectService.collectionSearchAction(searchAction);
        return new Result(StatusCode.REQUEST_SUCCESS);
    }

    @GetMapping("/test")
    public void test(){
        recommendService.test();
    }
    @PostMapping("/uploadVideoInfo")
    public Result uploadVideoInfo(@RequestBody Video video){
        collectService.uploadVideoInfo(video);
        return new Result(StatusCode.REQUEST_SUCCESS);
    }
}
